<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>权限设置列表</title>
    <link rel="stylesheet" href="__ACSS__/table.css">
    <link rel="stylesheet" href="__ACSS__/message.css">
    <link rel="stylesheet" href="__ACSS__/zeroModal.css">
    <script src="__AJS__/jquery-3.3.1.min.js"></script>
    <script src="__AJS__/common.js"></script>
    <script src="__AJS__/message.min.js"></script>
    <script src="__AJS__/zeroModal.min.js"></script>
</head>
<body>
    <div class="table-wrap">
        <div class="table-main">
            <div class="ibox-title">
                <h3>权限设置列表(方法)</h3>
            </div>
            <div class="ibox-content">  
                <form action="index.php" class="form-main" method="get">
                    <input type="hidden" name="c" value="user">
                    <div class="form-btn">
                        <a href="{:url('admin/admin_node/createmethod',['pid'=>$pid])}" target="myIframe">+ 新增权限节点 Method</a>
                    </div>
                </form>
                <table class="list-table">
                    <thead>
                        <tr>
                            <th width="8%">ID</th>
                            <th width="15%">权限节点(控制器)</th>
                            <th width="15%">权限中文标题</th>
                            <th width="10%">级别</th>
                            <th width="10%">父ID(控制器)</th>
                            <th width="10%">备注</th>
                            <th width="10%">排序</th>
                            <th width="5%">状态</th>
                            <th width="20%">操作</th>
                       </tr>
                    </thead>
                    <tbody>
        
                        {volist name="res" id="v"}
                            <tr>
                                <td>{$v.id}</td>
                                <td>{$v.name}</td>
                                <td>{$v.title}</td>
                                <td>{$v.level}</td>
                                <td>{$v.pid}</td>
                                <td>{$v.remark}</td>
                                <td>{$v.sort}</td>
                                <td>
                                    <a href>{$v.status}</a>
                                </td>
                                <td>
                                    <div class="btn-group">
                                        <a href="{:url('admin/admin_node/editmethod', ['id' => $v.id ])}" class="btn-white">编辑</a>
                                        <a href="javaScript:void(0)" data-id="{$v.id}" class="btn-white delete-btn">删除</a>
                                    </div>
                                </td>
                            </tr>
                        {/volist}
                    </tbody>
                </table>
                <div class="btn-limit-group">
                    <div class="btn">
                        <a href=""> << </a>
                        <a href=""> 1 </a>
                        <a href=""> 2 </a>
                        <a href=""> 3 </a>
                        <a href=""> 33 </a>
                        <a href=""> 333 </a>
                        <a href=""> 3333 </a>
                        <a href=""> >> </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>

        $(function () {
            // 触发提交删除用户
            $('.delete-btn').click(function () {

                var uid = $(this).attr('data-id');
                var obj = $(this).parents('tr');

                zeroModal.confirm({
                    content: '您确定删除吗？',
                        contentDetail: '删除后将无法恢复!',
                        okFn: function() {
                        // 执行添加操作
                        delAjax(uid, obj);
                    }
                });

            });
        });

        // 执行AJAX删除数据
        function delAjax(uid, obj) {
            $.ajax({
                type: 'delete',
                url: '/admin/user/delete/uid/' + uid,
                dataType: 'json',
                success: function (data) {
                    if (data.status) {
                        zeroModal.success(data.info);
                        obj.remove();
                    } else {
                        zeroModal.error(data.info);
                    }
                },
                error: function (data) {
                    alert('AJAX执行失败!');
                }
            });
        }
    </script>
</body>
</html>